home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************************
-
- MODULE
- DYN.h
-
- DESCRIPTION
- Header File for ``Dynamic Strings''
-
- HISTORY
- 29-09-94 b_noll created
- 13-11-94 b_noll renamed fields
-
- ******************************************************************************/
-
- #ifndef DYN_H
- #define DYN_H 1
-
- /**************************************
- Includes
- **************************************/
-
- #ifndef EXEC_TYPES_H
- #include <exec/types.h>
- #endif /* EXEC_TYPES_H */
-
- #include <stdarg.h>
-
- /**************************************
- Defines & Structures
- **************************************/
-
- struct _DSTR {
- int Size;
- int Length;
- UBYTE str[1];
- }; /* struct DSTR */
- #define DSTR struct _DSTR *
- #define EmptyDyn NULL
-
- /**************************************
- Prototypes
- **************************************/
-
- void DynInit (DSTR *pstr);
- void DynClear (DSTR *pstr);
- void DynDelete (DSTR *pstr);
- void DynReset (DSTR *pstr);
- void DynErase (DSTR *pstr);
- char *DynValue (DSTR *pstr);
- int DynSize (DSTR *pstr);
- int DynLen (DSTR *pstr);
- BOOL DynDel (DSTR *pstr, int pos, int chars);
- BOOL DynExpand (DSTR *pstr, int max);
- BOOL DynIns (DSTR *pstr, const char *src, int pos);
- BOOL DynCat (DSTR *pstr, const char *src);
- BOOL DynCpy (DSTR *pstr, const char *src);
- BOOL DynSCpy (DSTR *pstr, const char *src);
- BOOL DynDIns (DSTR *pstr, DSTR *src, int pos);
- BOOL DynDCat (DSTR *pstr, DSTR *src);
- BOOL DynDCpy (DSTR *pstr, DSTR *src);
- BOOL DynDSCpy (DSTR *pstr, DSTR *src);
- BOOL vDynAppend (DSTR *pstr, int num, va_list adds);
- BOOL vDynPrintf (DSTR *pstr, const char *tplt, va_list args);
- int DynPutc (DSTR *pstr, int chr);
- BOOL DynGetFile(DSTR *pstr, const char *name);
-
- #ifdef STREAM /* ---- Really so ? */
- BOOL DynGIns (DSTR *pstr, int pos, STREAM instream, char *(read)(STREAM));
- #endif
-
- #ifndef NO_DYNSTR_MACROS
- #define BRA_ do{
- #define KET_ }while(0)
-
- #define DynInit(pstr) *(pstr) = EmptyDyn
- #define DynDelete(pstr) DynClear(pstr)
- #define DynClear(pstr) BRA_ DSTR d;if((d=*(pstr)))free(d);*(pstr)=EmptyDyn; KET_
- #define DynReset(pstr) BRA_ DSTR d;if((d=*(pstr)))d->Length=strlen(d->Str); KET_
- #define DynErase(pstr) BRA_ DSTR d;if((d=*(pstr)))d->Length=d->Str[0]=0; KET_
- #define DynValue(pstr) ((*(pstr))? ((*(pstr))->Str): "")
- #define DynSize(pstr) ((*(pstr))? ((*(pstr))->Size): 0)
- #define DynLen(pstr) ((*(pstr))? ((*(pstr))->Length): 0)
-
- #endif /* !NO_DYNSTR_MACROS */
- #endif /* !DYN_H */
-
- /******************************************************************************
- ***** END DYN.h
- ******************************************************************************/
-